package com.itzzj.common.response;

import com.itzzj.common.enums.ResultCode;
import lombok.Data;

import java.io.Serializable;

/**
 * 同一 API 响应结果格式封装
 * @param <T>
 */
@Data
public class Result<T> implements Serializable {

    private Integer code;
    private String message;
    private T data;

    public Result setResult(ResultCode resultCode){
        this.code = resultCode.getCode();
        this.message = resultCode.getMessage();
        return this;
    }

    public Result setResult(ResultCode resultCode, T data){
        this.code = resultCode.getCode();
        this.message = resultCode.getMessage();
        this.setData(data);
        return this;
    }
}












































































